#ifndef __WORKER_H_
#define __WORKER_H_

#include "../../API/Tasks/_Task.h"

#include <pthread.h>
#include <sched.h>
#include <semaphore.h>

using namespace skelepp::API::Tasks;

namespace skelepp {
	namespace Core {
		namespace Tasking {
			class Worker {
			private:
				bool _busy;
				_Task *_current;
				pthread_t _worker;
				pthread_mutex_t _lock;

				static void *_run(void *worker)
				{
					Worker *result = (Worker *)worker;
					result->run();
					return NULL;
				}

				void run(void);
			public:
				Worker(void);
				~Worker(void);

				void start(void);
				void stop(void);
				void perform(_Task *task);

				bool is_busy(void);
			};
		}
	}
}

#endif